#ifndef EQOPWIDGET_H
#define EQOPWIDGET_H

#include "adaptivewidgets.h"
#include "qvaluespinbox.h"
#include "dm/dmstruct.h"

class EqOperator : public QObject
{
    Q_OBJECT
public:
    explicit EqOperator(const int &index, const EQ &eq, QWidget *parent = nullptr);
    EQ value() const;
    bool bypass() const;
    ACheckBox *checkBox;
    ASpinBox *freqSpinBox;
    QValueSpinBox *qSpinBox;
    ADoubleSpinBox *gainSpinBox;
    AComboBox *typeComboBox;
public slots:
    void set(const EQ &eq, bool init);
    void reset();
    void setBypass(bool checked);
signals:
    void stateChanged(int, EQ, bool);
private slots:
    void valueChanged();
    void gainSpinBoxChanged(const double &value);
    void checkBoxClicked(bool checked);
    void typeComboBoxIndexChanged(const int &index);
private:
    void setBlockSignals(bool block);
private:
    const int m_index;
    const EQ m_eq;
    double m_lastGain;

};

class EqOpWidget : public AGroupBox
{
    Q_OBJECT
public:
    explicit EqOpWidget(const QList<EQ> &list, QWidget *parent = nullptr);
public slots:
    void set(const int &index, const EQ &eq, bool init);
signals:
    void stateChanged(int, EQ, bool);
private slots:
    void reset();
    void bypassClicked(bool checked);
private:
    AScrollArea *scrollArea;
    AWidget *widget;
    APushButton *resetButton;
    APushButton *bypassButton;
    QList<EqOperator *> m_opList;
};

#endif // EQOPWIDGET_H
